<?php
/**
 * Description of Image
 *
 * @author NguyenVanTien
 */
class Zend_View_Helper_ImagePath extends Zend_View_Helper_Abstract {
    
    /**
     * Maximum number of file in folder
     * @var string $_numberSigleFile 
     */
    private $_numberSigleFile = 500;

    public function imagePath($folder, $id, $fileName, $thumnail = null){
        
        //If id not is numberic, return null
        if(!is_numeric($id)){
            return null;
        }
        
        //If empty file name, return null
        if(empty($fileName)){
            return $folder.'/default/default.gif';
        }
        
        
        //Find number folder and return image path
        $folderName = round(((int)$id/$this->_numberSigleFile));
        
        //find folder name thumnail
        if(!empty ($thumnail)){
            $folderName = 'thumnail/'.$thumnail.'/'.$folderName;
        }
        
        return $folder.'/'.$folderName.'/'.$fileName;
    }
}